AI3DHDrawingEditor Class Reference

instant3Dhub: AI3DHDrawingEditor Class Reference
instant3Dhub

#include "I3DHDrawingEditor.h"

+ Inheritance diagram for AI3DHDrawingEditor:
+ Collaboration diagram for AI3DHDrawingEditor:

Detailed Description

DrawingEditor Actor for creating spline 3D drawings in the scene that are synced to the session when finished.

For now splines are limited to "linear splines". A "linear spline" denotes a series of points that are connected by a segment mesh of constant thickness and color.

Note:

  • The class creates one geometry per spline which might not render efficiently when there are a lot of spline. The geometry-per-spline granularity was chosen to keep the finalized data simple for post-processing / export.

(Blueprint) Class Setup:

  • Select meshes to render the joints (usually a sphere) and segments (usually a cylinder with pivot at its base, standing up in the z-direction). The mesh sizes define the units of the spline size at scale == 1. Both meshes need to be CPU accessible to create the geometry in the finalization step.

Typical usage:

  • To create a DrawingEditor see UI3DHAppUtilities::CreateDrawingEditor
  • MoveCursorTo moves the drawing cursor in the scene. The cursor is visible while in Draw Mode and shows where the user would place new spline point.
  • AddPointAtCursor adds a new point to the active spline (usually the last created) or creates a new one if there is none.
  • BeginNewSplineSlice assigns future points to a new SplineSlice that can be removed in one step by calling RemoveLastSplineSlice().
  • BeginNewSpline ends the currently active Spline and begins a new one. Allows to draw disconnected Splines in a single drawing.
  • CreateHubDrawingAndDestroy finalizes the drawing with all splines in it, syncs it with the session and destroys this actor.

Implementation-wise each spline is rendered by two InstancedStaticMeshComponent, one for the joints, one for the segments.

Public Member Functions

AI3DHConnectorGetHubConnector () const
 
void SetDrawingColor (const FLinearColor &Color)
 
FLinearColor GetDrawingColor () const
 
void SetDrawingScale (const double &Scale)
 
double GetDrawingScale () const
 
void SetOmitStrokeStartAndEndJoints (bool bNewOmitJoints)
 
void SetShowActiveSliceControlPoints (bool bNewShowActiveSliceControlPoints)
 
bool IsEmpty () const
 
int32 NumSplines () const
 
void Clear ()
 
void MoveCursorTo (const FVector &Location)
 
void AddPointAtCursor ()
 
void BeginNewSplineSlice ()
 
bool RemoveLastSplineSlice ()
 
void BeginNewSpline ()
 
void FinalizeDrawing (TUniqueFunction< void(FI3DHDrawingResult, TArray< FI3DHSplineData > OutSplines)> OnComplete)
 
void CreateHubDrawingAndDestroy (const FString &Name, TUniqueFunction< void(int DrawingHandle, EI3DHErrorCode ErrorCode)> OnComplete)
 
void SetDrawingMode (EI3DHDrawingEditorMode InDrawingMode)
 
EI3DHDrawingEditorMode GetDrawingEditorMode () const
 
bool AddPoint (const FVector &Location, bool bIsWorldSpace=false)
 
void InitFromSplines (const TArray< FI3DHSplineData > &InSplines)
 
const TArray< FI3DHSplineData > & GetSplines () const
 
bool SelectNearestPointAtCursor ()
 
bool SelectNearestPoint (const FVector &Location, bool bIsWorldSpace=false)
 

Static Public Member Functions

static AI3DHDrawingEditorCreateDrawingEditor (AI3DHConnector *HubConnector, TSubclassOf< AI3DHDrawingEditor > DrawingClass)
 

Public Attributes

double MinimumPointDistance = 3.0
 
double HoverPointDistance = 1.0
 
FString ThumbnailBase64DataURI
 

Member Function Documentation

◆ AddPoint()

bool AI3DHDrawingEditor::AddPoint ( const FVector & Location,
bool bIsWorldSpace = false )

Adds a spline point at the provided relative or world position to the active spline.

If no spline is active, a new one is created. New Points are not added if the cursor position is within a range to the previous point defined by MinimumPointDistance.

Parameters
LocationThe location.
bIsWorldSpaceLocation is used local space to this Actor unless bIsWorldSpace is true.
Returns
True if it succeeds, false if it fails.
See also
AI3DHDrawingEditor::MinimumPointDistance

◆ AddPointAtCursor()

void AI3DHDrawingEditor::AddPointAtCursor ( )

Adds a spline point at the cursor position to the active spline.

If no spline is active, a new one is created. New Points are not added if the cursor position is within a range to the previous point defined by MinimumPointDistance.

See also
AI3DHDrawingEditor::MinimumPointDistance

◆ BeginNewSpline()

void AI3DHDrawingEditor::BeginNewSpline ( )

Begins a New Splines that is discontinuous from any previous spline.

Does not create a new Spline if the currently active Spline is empty.

◆ BeginNewSplineSlice()

void AI3DHDrawingEditor::BeginNewSplineSlice ( )

Begins a new Spline Slice which means the next point added will be part of a new Slice.

A Spline Slice groups a range of points within a Spline together, allowing for operations to be applied to a set of points at once. Common use case is to group points together and remove them in a single operation using RemoveLastSplineSlice.

See also
AI3DHDrawingEditor::RemoveLastSplineSlice

◆ CreateDrawingEditor()

static AI3DHDrawingEditor * AI3DHDrawingEditor::CreateDrawingEditor ( AI3DHConnector * HubConnector,
TSubclassOf< AI3DHDrawingEditor > DrawingClass )
static

Creates an actor which can be used for drawing and syncing to the Hub when finished.

Parameters
HubConnectorThe hub connector.
DrawingClassThe drawing class.
Returns
Nullptr if it fails, else the new drawing editor.

◆ CreateHubDrawingAndDestroy()

void AI3DHDrawingEditor::CreateHubDrawingAndDestroy ( const FString & Name,
TUniqueFunction< void(int DrawingHandle, EI3DHErrorCode ErrorCode)> OnComplete )

Finalizes the drawing, synchronizes it with the hub and destroys this actor.

Note
Must be called from the game thread.
Empty drawings are not allowed. If the drawing is empty, synchronization with the hub is skipped and OnComplete is called with OnComplete(0, EI3DHErrorCode::Success).
Parameters
NameThe name of the drawing.
OnCompleteCallback called on completion.

◆ FinalizeDrawing()

void AI3DHDrawingEditor::FinalizeDrawing ( TUniqueFunction< void(FI3DHDrawingResult, TArray< FI3DHSplineData > OutSplines)> OnComplete)

Finalizes the drawing and builds the drawing geometry.

This disables further editing of the drawing.

Note
The output coordinates are relative to this actor (which should be attached to the HubConnector).
Must be called from the game thread.
Parameters
OnCompleteCallback called on completion.
Experimental
The handling of SplineData is not yet finalized, the callback signature might change.
Experimental
Introduced in v0.0.25. "The handling of SplineData is not yet finalized, the callback signature might change."
This API is experimental. As such, there is no guarantee that it won't change or be removed in future releases. Please use at your own risk.

◆ GetDrawingColor()

FLinearColor AI3DHDrawingEditor::GetDrawingColor ( ) const

Retrieves the color currently used for drawing.

Returns
The drawing color.

◆ GetDrawingEditorMode()

EI3DHDrawingEditorMode AI3DHDrawingEditor::GetDrawingEditorMode ( ) const
inline

Returns the Drawing Mode of the DrawingEditor.

Returns
The drawing mode.

◆ GetDrawingScale()

double AI3DHDrawingEditor::GetDrawingScale ( ) const

Retrieves the scale currently used for drawing.

Returns
The drawing scale.

◆ GetHubConnector()

AI3DHConnector * AI3DHDrawingEditor::GetHubConnector ( ) const
inline

Returns the parent hub connector.

Returns
The parent hub connector.

◆ GetSplines()

const TArray< FI3DHSplineData > & AI3DHDrawingEditor::GetSplines ( ) const
inline

Returns the SplineData Array of all Splines that are part of this DrawingEditor.

Note
Points returned by this function are relative to this Actor. This contrasts points passed to the OnDrawingFinalized event which are relative to the parent Actor.
Returns
The splines.
See also
CreateHubDrawingAndDestroy

◆ InitFromSplines()

void AI3DHDrawingEditor::InitFromSplines ( const TArray< FI3DHSplineData > & InSplines)

Clears all Splines that currently exist (if any) and initializes the DrawingEditor from the provided Splines.

Parameters
InSplinesThe new set of splines.

◆ IsEmpty()

bool AI3DHDrawingEditor::IsEmpty ( ) const

Returns true if the drawing has no splines.

Returns
True if empty, false if not.

◆ MoveCursorTo()

void AI3DHDrawingEditor::MoveCursorTo ( const FVector & Location)

Sets the cursor position.

Note
Only available in EI3DHDrawingEditorMode::Draw
Parameters
LocationThe location.

◆ NumSplines()

int32 AI3DHDrawingEditor::NumSplines ( ) const

Returns the number of splines the drawing consists of.

Note
Includes potential empty Splines. Use AI3DHDrawingEditor::IsEmpty to check if empty.
Returns
The total number of splines.

◆ RemoveLastSplineSlice()

bool AI3DHDrawingEditor::RemoveLastSplineSlice ( )

Removes the last SplineSplice from the active Spline.

Returns
True if the removed SplineSlice was the last.

◆ SelectNearestPoint()

bool AI3DHDrawingEditor::SelectNearestPoint ( const FVector & Location,
bool bIsWorldSpace = false )

Tries to select and activate the Nearest Point that is closer to the supplied Location than the HoverPointDistance.

Parameters
LocationThe location.
bIsWorldSpaceLocation is used local space to this Actor unless bIsWorldSpace is true.
Returns
True if nearest Point was found and selected. False if no nearest Point was found or nearest Point was already selected.
See also
HoverPointDistance

◆ SelectNearestPointAtCursor()

bool AI3DHDrawingEditor::SelectNearestPointAtCursor ( )

Tries to select and activate the Nearest Point that is closer to the Cursor than the HoverPointDistance.

Returns
True if nearest Point was found and selected. False if no nearest Point was found or nearest Point was already selected.

◆ SetDrawingColor()

void AI3DHDrawingEditor::SetDrawingColor ( const FLinearColor & Color)

Sets the color used for drawing and applies it to the active spline.

Parameters
ColorThe drawing color.

◆ SetDrawingMode()

void AI3DHDrawingEditor::SetDrawingMode ( EI3DHDrawingEditorMode InDrawingMode)

Sets the Drawing Mode of the DrawingEditor.

Parameters
InDrawingModeThe new drawing mode.

◆ SetDrawingScale()

void AI3DHDrawingEditor::SetDrawingScale ( const double & Scale)

Sets the scale used for drawing and applies it to the active spline.

Parameters
ScaleThe drawing scale.

◆ SetOmitStrokeStartAndEndJoints()

void AI3DHDrawingEditor::SetOmitStrokeStartAndEndJoints ( bool bNewOmitJoints)

Controls whether the first and last sample point of Splines are rendered with a joint.

Parameters
bNewOmitJointsTrue to omit joints.

◆ SetShowActiveSliceControlPoints()

void AI3DHDrawingEditor::SetShowActiveSliceControlPoints ( bool bNewShowActiveSliceControlPoints)

Controls whether all ControlPoints belonging to the active SplineSlice should be visualized.

Parameters
bNewShowActiveSliceControlPointsTrue to show all active slice control points.

Member Data Documentation

◆ ThumbnailBase64DataURI

FString AI3DHDrawingEditor::ThumbnailBase64DataURI

Data-URI string, e.g.

"data:image/svg+xml;base64,<BASE 64 ENCODED SVG>".


The documentation for this class was generated from the following file: